package com.example.highperformanceandroidtech.fragment;

import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.PaintDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.ArcShape;
import android.graphics.drawable.shapes.OvalShape;
import android.graphics.drawable.shapes.RectShape;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.highperformanceandroidtech.R;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link Example1_1Fragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class Example1_1Fragment extends Fragment {

    public Example1_1Fragment() {
    }

    public static Example1_1Fragment newInstance(String param1, String param2) {
        Example1_1Fragment fragment = new Example1_1Fragment();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_simple1_1, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        PaintDrawable paintDrawable = new PaintDrawable(Color.GREEN);
        paintDrawable.setCornerRadius(30);
        view.findViewById(R.id.textView1).setBackgroundDrawable(paintDrawable);

        OvalShape ovalShape = new OvalShape();
        ShapeDrawable shapeDrawable = new ShapeDrawable(ovalShape);
        shapeDrawable.getPaint().setColor(Color.BLUE);
        shapeDrawable.getPaint().setStyle(Paint.Style.FILL);
        view.findViewById(R.id.textView2).setBackground(shapeDrawable);

        RectShape rectShape = new RectShape();
        ShapeDrawable rectShapeDrawable = new ShapeDrawable(rectShape);
        rectShapeDrawable.getPaint().setColor(Color.RED);
        rectShapeDrawable.getPaint().setStyle(Paint.Style.FILL);
        view.findViewById(R.id.textView3).setBackground(rectShapeDrawable);

        ArcShape arcShape = new ArcShape(30,180);
        ShapeDrawable arcShapeDrawable = new ShapeDrawable(arcShape);
        arcShapeDrawable.getPaint().setColor(Color.YELLOW);
        arcShapeDrawable.getPaint().setStyle(Paint.Style.FILL);
        view.findViewById(R.id.textView4).setBackground(arcShapeDrawable);
    }
}